There are many ways in which we can loop through an array:
forEach: available on array instance
for
for in
for of
map: available on array instance
reduce: available on array instance
The forEach() method of Array instances executes a provided function once for each array element.
The for loop
The for...in statement iterates over all enumerable string properties of an object (ignoring properties keyed by symbols), including inherited enumerable properties.
The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include instances of built-ins such as Array, String, TypedArray, Map, Set, NodeList (and other DOM collections), as well as the arguments object, generators produced by generator functions, and user-defined iterables.
The map() method of Array instances creates a new array populated with the results of calling a provided function on every element in the calling array.
The reduce() method of Array instances executes a user-supplied "reducer" callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value.